package com.hxalex.simulationhandle.accessbilityService.receiver.wifi;

import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;

import com.hxalex.simulationhandle.accessbilityService.manger.WifiManger;
import com.hxalex.simulationhandle.accessbilityService.receiver.base.BaseReceiver;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by hx_Alex on 2018/5/26.
 */

public class BackWifiInMainReceiver extends BaseReceiver  {

    private AccessibilityNodeInfo info;
    private onBackToAppMainListener onBackToAppMainListener;
    private boolean isComplete=false;
    public void setOnBackToAppMainListener(BackWifiInMainReceiver.onBackToAppMainListener onBackToAppMainListener) {
        this.onBackToAppMainListener = onBackToAppMainListener;
    }

    public BackWifiInMainReceiver(WifiManger wifiManger) {
        super(wifiManger);
        FLAG="回退至wifi主页命令";
    }


    public AccessibilityNodeInfo getInfo() {
        return info;
    }

    public void setInfo(AccessibilityNodeInfo info) {
        this.info = info;
    }

    @Override
    public void doSomething() {
        if(!isPrintCommandMsg)
        {
            Log.w("BackWifiInMainReceiver","开始执行"+FLAG);
            isPrintCommandMsg=true;
        }

            Timer timer=new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                if(!isComplete)
                onBackToAppMainListener.onBackToApp();
                isComplete=true;
                commandCompleteListener.commandCompleteListener();
            }
        },5000);
        
        
        }
    


    public interface onBackToAppMainListener {
        void onBackToApp();
    }
}
